/* eslint-disable */
let AdditionProp = require("../dbSync").Game.AdditionProp
let propShopName = ["小卖部", "奶茶店", "水果店", "宠物店", "美容店", "寿司馆", "电影院", "健身房", "百货超市", "蛋糕店", "咖啡馆", "西餐厅", "婚庆点", "珠宝店", "体育馆", "星级酒店", "购物广场", "商业大楼"]
let id = 1
/**
 * 
 * @param {{number}} cost_type 
 * @param {{price:number,value:string}} obj 
 */
function toMyprop(cost_type, obj) {
	let tool_type
	let detail
	let price = Number(obj.price)
	let prop_name
	if (obj.value.startsWith("autoProduceX1Xcrop")) {
		tool_type = 2
		detail = {num: obj.value.split("=").pop()}
		prop_name = `${propShopName[detail.num - 1]}自动化经营`
	} else if (obj.value.startsWith("sceneCutTime")) {
		tool_type = 3
		detail = {num: 50}
		prop_name = "所有商店经营时间减50%"
	}
	else if (obj.value.startsWith("sceneTimeAhead")) {
		tool_type = 7
		detail = {num: obj.value.split("X").pop()}
		prop_name = `增加${detail.num}小时经营收益`
	} else if (obj.value.startsWith("sceneProfit")) {
		tool_type = 1
		detail = {num: obj.value.split("X").pop()}
		prop_name = `所有收益X${detail.num}`
	} else if (obj.value.startsWith("sceneTrophyBoost")) {
		tool_type = 4
		detail = {
			num: Number(obj.value.split("X").pop()) * 100
		}
		prop_name = `每个声望增加${detail.num}%的收益收成`
	} else if (obj.value.startsWith("sceneGemProfit")) {
		tool_type = 5
		detail = {num: obj.value.split("X").pop()}
		prop_name = `经营收益永久增加${detail.num}倍`
	} else if (obj.value.startsWith("sceneMagicTrophiesX")) {
		tool_type = 6
		detail = {
			num: obj.value.split("X").pop()
		}
		prop_name = "直接获得{detail.num}声望"
	}
	else {
		throw obj.value
	}
	detail.num = Number(detail.num)
	// console.log({tool_type, detail, cost_type, price})
	// return {tool_type, detail, cost_type, price, prop_name, id: id++}
	return {map_id: obj.map_id, aid: 6, tool_type, detail, cost_type, price, prop_name}//prop_name,
}

function getProps() {
	let v = require("../../data/xt/prop")
	// let x = [].concat(v.coin, v.popularity, v.sycee)
	let x = []
	v.coin.forEach((v, i) => {
		if (i < 84)
			v.map_id = 1
		else if (i < 170)
			v.map_id = 2
		else {
			v.map_id = 3
			x.push(toMyprop.bind({}, 1)(v))
		}
	})

	v.popularity.forEach((v, i) => {
		if (i < 88)
			v.map_id = 1
		else if (i < 178)
			v.map_id = 2
		else {
			v.map_id = 3
			x.push(toMyprop.bind({}, 2)(v))
		}
	})

	v.sycee.forEach((v, i) => {
		if (i < 6)
			v.map_id = 1
		else if (i < 12)
			v.map_id = 2
		else {
			v.map_id = 3
			x.push(toMyprop.bind({}, 3)(v))
		}
	})
	// console.table(x)
	return x
}

async function test(arrs) {
/* 	for (let i = 0; i < arrs.length; i++) {
		let store = AdditionProp.build(arrs[i], {isNewRecord: true})//, 
		let res = await store.save()
		// console.log(JSON.stringify(res))
	} */
}
test(getProps())
// node dbServer/save1/saveProp.js